
import VueRouter from "vue-router";
import UserView from "../views/manage/UserView.vue";
import Layout from "../layout/Layout.vue";
import Shop from "../views/shop/Shop.vue";
import MyLayout from "../layout/MyLayout.vue";
import ShoppingCart from "../views/shop/ShoppingCart.vue";
import MyOrder from "../views/shop/MyOrder.vue";
import Login from "../views/Login.vue";
import Register from "@/views/Register.vue";
import ShopLayout from "@/layout/ShopLayout.vue";
import Detail from "@/views/shop/Detail.vue";
import ProfileView from "@/views/shop/ProfileView.vue";
import OrderView from "@/views/manage/OrderView.vue";
import ItemView from "@/views/manage/ItemView.vue";
import PersonView from "@/views/manage/PersonView.vue";
import Index from "@/views/shop/Index.vue";

const routes = [
  //   管理路由
  {
    //当一个框架有默认的子路由的时候就不需要名称，将子路由写为'/'就可以了
    path: "/home",
    component: Layout,
    // 管理子路由
    children: [
      {
        path: "/",
        alias: "/user",
        name: "user",
        component: UserView,
      },
      {
        path: "/person",
        name: "person",
        component: PersonView,
      },
      {
        path: "/item",
        name: "item",
        component: ItemView,
      },
      {
        path: "/order",
        name: "order",
        component: OrderView,
      },
    ],
  },
  //   登录路由
  {
    path: "/",
    name: "Index",
    component: Index,
  },
    //  搜索路由
    {
      path: "/shop",
      name: "Shop",
      component: Shop,
    },
  //   注册路由
  {
    path: "/register",
    name: "Register",
    component: Register,
  },
  //   注册路由
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  //   商城路由
  {
    path: "/shop",
    component: ShopLayout,
    // 商城子路由
    children: [
      {
        path: "/",
        name: "shop",
        component: Shop,
      },
      {
        path: "/shop/detail",
        name: "detail",
        component: Detail,
      },
      {
        path: "/mine",
        component: MyLayout,
        // 我的淘宝子路由
        children: [
          {
            path: "/",
            name: "profile",
            component: ProfileView,
          },
          {
            path: "/cart",
            name: "ShoppingCart",
            component: ShoppingCart,
          },
          {
            path: "/myOrder",
            name: "myOrderView",
            component: MyOrder,
          },
        ],
      },
    ],
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
